<?php

declare(strict_types=1);
/**
 * This file is part of MineAdmin.
 *
 * @link     https://www.mineadmin.com
 * @document https://doc.mineadmin.com
 * @contact  root@imoi.cn
 * @license  https://github.com/mineadmin/MineAdmin/blob/master/LICENSE
 */

namespace App\Http\Admin\Request\Course;

use App\Schema\Course\CourseTaskSchema;
use Hyperf\Validation\Request\FormRequest;
use Mine\Swagger\Attributes\FormRequest as FormRequestAnnotation;

#[FormRequestAnnotation(
    schema: CourseTaskSchema::class,
    title: '创建课时',
    required: [
        'name'
    ],
    only: [
        'name'
    ]
)]
class CourseTaskRequest extends FormRequest
{
    public function authorize(): bool
    {
        return true;
    }

    public function rules(): array
    {
        return [
            'course_id' => 'required|integer',
            'section_id' => 'required|integer',
            'is_publish' => 'required|integer',
            'taskable' => 'required|array',
            'taskable_type' => 'required|string',
            'extras' => 'array'
        ];
    }

    public function attributes(): array
    {
        return [
            'course_id' => trans('course-task.course_id'),
            'section_id' => trans('course-task.section_id'),
            'is_publish' => trans('course-task.is_publish'),
            'taskable' => trans('course-task.taskable'),
            'taskable_type' => trans('course-task.taskable_type'),
        ];
    }
}
